import 'package:enterprise_v6_app/app/components/custom_app_bar.dart';
import 'package:enterprise_v6_app/app/components/custom_refresh.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/ext/widget_extension.dart';
import 'package:enterprise_v6_app/app/data/entities/task/patrol_scheme_entity.dart';
import 'package:enterprise_v6_app/app/modules/task/task_all/hazard_investigation/investigation_plan/investigation_plan_controller.dart';

/// 隐患排查-排查计划页面
class InvestigationPlanPage extends StatelessWidget {
  InvestigationPlanPage({super.key});

  final controller = Get.put(InvestigationPlanController());

  /// 字体显示
  Widget _getTextView({required String leftText, required String rightText, Color? rightColor}) {
    return Expanded(
        child: Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Text(
          leftText,
          style: TextStyle(
            color: const Color(0xff5C6DFF),
            height: 1.2,
            fontWeight: FontWeight.w400,
            fontSize: 12.sp,
          ),
        ),
        AppGaps.hGap4,
        Text(
          rightText,
          style: TextStyle(
            color: rightColor ?? const Color(0xff5C6DFF),
            height: 1.2,
            fontWeight: FontWeight.w500,
            fontSize: 16.sp,
          ),
        )
        // Expanded(
        //     child: ),
      ],
    ));
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder(
        init: controller,
        builder: (_) {
          return Scaffold(
            appBar: CustomAppBar(
              titleText: '排查计划',
            ),
            body: Container(
              color: const Color(0xffF5F5F6),
              padding: EdgeInsets.symmetric(vertical: 12.w),
              child: CustomEasyRefreshList<PatrolSchemeEntity>(
                dataLoad: (pageIndex, pageSize, {String? search}) async {
                  return controller.getListData(pageIndex, pageSize);
                },
                itemBuilder: (PatrolSchemeEntity item, int index) {
                  return Container(
                    margin: EdgeInsets.symmetric(horizontal: 14.w),
                    decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(8.w))),
                    child: Column(
                      children: [
                        Container(
                          padding: EdgeInsets.symmetric(vertical: 10.w, horizontal: 13.w),
                          child: Row(
                            children: [
                              SvgPicture.asset(
                                AppImages.icon_title,
                                width: 20.w,
                                height: 20.w,
                              ),
                              AppGaps.hGap6,
                              Expanded(
                                  child: Text(
                                item.planName!,
                                style: TextStyle(color: const Color(0xff262F38), height: 1.2, fontWeight: FontWeight.w500, fontSize: 15.sp),
                              )),
                            ],
                          ),
                        ),
                        Container(
                          height: 1.w,
                          color: const Color(0xff587DF5).withOpacity(0.2),
                        ),
                        Container(
                          padding: EdgeInsets.symmetric(horizontal: 13.w, vertical: 12.w),
                          child: Column(
                            children: [
                              Row(
                                children: [
                                  Text(
                                    '排查类型：',
                                    style: TextStyle(color: const Color(0xffA5A6B5), height: 1.2, fontWeight: FontWeight.w400, fontSize: 13.sp),
                                  ),
                                  Expanded(
                                      child: Text(
                                    '${item.inspectionTypeName}',
                                    textAlign: TextAlign.right,
                                    style: TextStyle(color: const Color(0xff495061), height: 1.2, fontWeight: FontWeight.w500, fontSize: 12.sp),
                                  )),
                                ],
                              ),
                              AppGaps.vGap10,
                              Container(
                                padding: EdgeInsets.symmetric(vertical: 10.w),
                                decoration: BoxDecoration(color: const Color(0xffEEF0FF), borderRadius: BorderRadius.all(Radius.circular(8.w))),
                                child: Row(
                                  children: [
                                    _getTextView(leftText: '点位', rightText: '${item.numberOfPoints}'),
                                    Container(
                                      height: 16.w,
                                      width: 1.w,
                                      color: Colors.white,
                                    ),
                                    _getTextView(leftText: '任务', rightText: '${item.taskNum}'),
                                    Container(
                                      height: 16.w,
                                      width: 1.w,
                                      color: Colors.white,
                                    ),
                                    _getTextView(
                                      leftText: '未完成',
                                      rightText: '${item.theNumberOfTasksToBeCompleted}',
                                      rightColor: const Color(0xffFD6B6B),
                                    ),
                                  ],
                                ),
                              )
                            ],
                          ),
                        ),
                      ],
                    ),
                  ).clickOnce(() {
                    controller.goInspectionDetails(item.id);
                  });
                },
              ),
            ),
          );
        });
  }
}
